var _o116;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Shape = undefined;
var $2ObjUtil = require("ObjUtil");
var $2BaseUI = require("BaseUI");
var $2UIManager = require("UIManager");
var l;
(function (e) {
  e[e.Box = 0] = "Box";
  e[e.Circle = 1] = "Circle";
  e[e.Polygon = 2] = "Polygon";
})(l = exports.Shape || (exports.Shape = {}));
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_UIGuide = _o116 = /* */function (_a$BaseUI2) {
  function _ctor() {
    var _this100;
    babel_classCallCheck(this, _ctor);
    _this100 = _callSuper(this, _ctor, arguments);
    _this100.maskNode = null;
    _this100.hand = null;
    _this100.tagetNode = null;
    _this100.finish = false;
    return _this100;
  }
  babel_inherits(_ctor, _a$BaseUI2);
  return babel_createClass(_ctor, [{
    key: "onShow",
    value: function onShow() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onShow", this).call(this);
      this.finish = false;
    }
  }, {
    key: "init",
    value: function init(e, t, n, _o117) {
      var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : l.Box;
      var a = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
      this.tagetNode = e;
      var r = e.convertToWorldSpaceAR(cc.v2());
      var c = this.node.convertToNodeSpaceAR(r);
      this.maskNode.setPosition(c);
      this.maskNode.children[0].getComponent(cc.Widget).updateAlignment();
      this.hand.active = t;
      if (t) {
        cc.Tween.stopAllByTarget(this.hand);
        cc.tween(this.hand).sequence(cc.tween().by(.3, {
          y: -20
        }, {
          easing: "easeOutSine"
        }), cc.tween().by(.3, {
          y: 20
        }, {
          easing: "easeInSine"
        })).repeatForever().start();
      }
      if (i == l.Polygon) {
        var _e50 = [];
        for (var _n46 = 0; _n46 < a.length; _n46++) {
          _e50.push(this.maskNode.convertToNodeSpaceAR(a[_n46]));
        }
        var _t50 = $2ObjUtil.default.getgetCenterOfGravity(a);
        this.hand.setPosition(this.node.convertToNodeSpaceAR(_t50));
      } else {
        console.error("暂不支持该引导，请自行可扩展");
      }
      if (_o117 == cc.Node.EventType.TOUCH_END) {
        this.tagetNode.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
      } else {
        _o117 == cc.Node.EventType.TOUCH_START && this.tagetNode.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
      }
      this.tagetNode.mytouchtype = this.tagetNode._touchListener.swallowTouches;
      this.tagetNode._touchListener.setSwallowTouches(false);
    }
  }, {
    key: "onTouchEnd",
    value: function onTouchEnd(e) {
      this.finish = true;
      e.getCurrentTarget().off(cc.Node.EventType.TOUCH_START, this.onTouchEnd, this);
    }
  }, {
    key: "onTouchStart",
    value: function onTouchStart(e) {
      this.finish = true;
      e.getCurrentTarget().off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
    }
  }, {
    key: "lateUpdate",
    value: function lateUpdate() {
      if (this.finish) {
        this.tagetNode && this.tagetNode._touchListener && this.tagetNode._touchListener.setSwallowTouches(this.tagetNode.mytouchtype);
        this.close();
      }
    }
  }, {
    key: "close",
    value: function close() {
      this.tagetNode = null;
      $2UIManager.UIManager.getInstance().hideUI(_o116);
    }
  }]);
}($2BaseUI.BaseUI);
def_UIGuide.className = "UIGuide";
def_UIGuide.layertype = $2UIManager.layerType.Guide;
def_UIGuide.isMask = false;
def_UIGuide.automatic = false;
cc__decorate([ccp_property(cc.Node)], def_UIGuide.prototype, "maskNode", undefined);
cc__decorate([ccp_property(cc.Node)], def_UIGuide.prototype, "hand", undefined);
def_UIGuide = _o116 = cc__decorate([ccp_ccclass], def_UIGuide);
exports.default = def_UIGuide;